package main

import (
	"bytes"
	"context"
	"encoding/json"
	"google.golang.org/grpc/metadata"
	"kop/modules/award/models"
	"kop/modules/role/client"
	"kop/pb"
	"log"
	"time"
)

func main() {

	var award pb.Award
	award.Exp = 10
	award.ItemIDs = []*pb.RawItem{{ItemID: 101001, Number: 5}, {ItemID: 101002, Number: 5}}
	award.RingIDs = []int32{3064}
	award.Coin = 22000
	award.Gold = 1000
	award.Diamond = 555
	award.Rum = 111

	var role = client.GetRole(3)

	var err = models.SendAward(role, &award, nil)

	log.Println(*award.Money)

	log.Println(err)

	var b, _ = json.Marshal(award)

	var str bytes.Buffer
	_ = json.Indent(&str, b, "", "    ")

	log.Println(str.String())

}

func ctx(token string) (context.Context, context.CancelFunc) {
	ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
	ctx = metadata.NewOutgoingContext(ctx, metadata.New(map[string]string{"token": token}))
	return ctx, cancel
}
